package com.springcloud.auth.authorization.provider;

import com.springcloud.auth.authorization.provider.fallback.SystemUserProviderFallback;
import com.springcloud.common.core.entity.R;
import com.springcloud.common.entity.SystemRole;
import com.springcloud.common.entity.SystemUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Set;

/**
 * <p>  </p>
 *
 * @author mori
 * @since 11/4/2019 3:26 PM
 */
@FeignClient(name = "system-user-service",fallback = SystemUserProviderFallback.class)
public interface SystemUserProvider {

    /**
     * 根据username获取SystemUser对象
     *
     * @param username
     * @return
     */
    @GetMapping("/user/name")
    R<SystemUser> getSystemUserByUsername(@RequestParam("username") String username);

    /**
     * 获取userId对应的角色列表
     *
     * @param userId
     * @return
     */
    @GetMapping(value = "/user/{userId}/role")
    R<Set<SystemRole>> getRoleListByUserId(@PathVariable("userId") Integer userId);
}
